{{- $content := .Content -}}
{{- $lang := .Lang -}}
{{- $params := .Page.Scratch.Get "params" -}}
{{- $maxShownLines := $params.code.maxShownLines | default 10 | int -}}
{{- $copy := $params.code.copy | default true -}}
{{- $lines := split $content "\n" | len -}}
{{- $options := dict "lineNoStart" 1 "lineNos" true -}}
{{- $options = .Options | partial "function/dict.html" | merge $options -}}
{{- $lineNoStart := $options.lineNoStart | int -}}
{{- $lineNos := $options.lineNos | partial "function/bool.html" -}}

{{- $options = dict "noClasses" false "lineNos" false | merge $options -}}
{{- $result := transform.Highlight $content $lang $options -}}
<div class="code-block{{ if $lineNos }} code-line-numbers{{ end }}{{ if le $lines $maxShownLines }} open{{ end }}" style="counter-reset: code-block {{ sub $lineNoStart 1 }}">
    <div class="code-header language-{{ $lang }}">
        <span class="code-title"><i class="arrow fas fa-angle-right fa-fw" aria-hidden="true"></i></span>
        <span class="ellipses"><i class="fas fa-ellipsis-h fa-fw" aria-hidden="true"></i></span>
        {{ if $copy }}<span class="copy" title="{{ T "copyToClipboard" }}"><i class="far fa-copy fa-fw" aria-hidden="true"></i></span>{{ end }}
    </div>
    {{- $result -}}
</div>
